//
// This file contains the definitions for OnInitialize and OnShutdown the IISHost/CasablancaHost will call.
//

#include "stdafx.h"

bool on_initialize(const std::vector<casablanca::string_t> &args, const std::vector<casablanca::string_t> &configs);
bool on_shutdown();

extern "C" __declspec(dllexport)
bool OnInitialize(const std::vector<casablanca::string_t> &args, const std::vector<casablanca::string_t> &configs)
{
    std::vector<casablanca::string_t> modified_configs(configs);

    // If running locally not in Azure we need to set the endpoints explicitly to be the public port.
    if(std::find(modified_configs.begin(), modified_configs.end(), U("EndPoint1")) == modified_configs.end())
    {
        modified_configs.push_back(U("EndPoint1"));
        modified_configs.push_back(U("30000"));
    }

    // No need to pass commandline args since it won't be used.
    return on_initialize(args, modified_configs);
}

extern "C" __declspec(dllexport)
bool OnShutdown()
{
    return on_shutdown();
}